package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.dao.provider.CarProvider;
import com.jinmdz.fmis.dao.admin.model.car.CarEditItem;
import com.jinmdz.fmis.dao.admin.model.car.CarListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.ArrayList;

/**
 * 接运车辆维护Dao
 *
 * @author LiCongLu
 * @date 2020-03-10 10:56
 */
public interface CarDao {

    /**
     * 查询接运车辆列表
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-03-10 10:58
     */
    @SelectProvider(type = CarProvider.class, method = "listCarList")
    ArrayList<CarListItem> listCarList();

    /**
     * 按照主键获取接运车辆信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-03-10 11:23
     */
    @Select(" select id,car_type_code,car_belong_code,car_code,car_no,transport_price" +
            " ,disable_state,driver_user_id,sort,remark,version " +
            " from transport_car where id = #{id} and deleted = 0 limit 1 ")
    CarEditItem getCarEditById(@Param("id") Integer id);

    /**
     * 按照车辆编号查询非当前车辆信息主键
     *
     * @param carId   当前车辆主键
     * @param carCode 车辆编号
     * @return
     * @author LiCongLu
     * @date 2020-03-10 11:50
     */
    @Select(" select id from transport_car where id != IFNULL(#{carId},0) and car_code = #{carCode} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getCarIdByCarCode(@Param("carId") Integer carId, @Param("carCode") String carCode);

    /**
     * 按照车辆编号查询非当前车辆信息主键
     *
     * @param carId 当前车辆主键
     * @param carNo 车牌号
     * @return
     * @author LiCongLu
     * @date 2020-03-10 11:50
     */
    @Select(" select id from transport_car where id != IFNULL(#{carId},0) and car_no = #{carNo} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getCarIdByCarNo(@Param("carId") Integer carId, @Param("carNo") String carNo);
}
